package com.dream.demo.controller;

import com.dream.demo.common.ResultCommon;
import com.dream.demo.pojo.User;
import com.dream.demo.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;


@RestController
public class UserController {

    @Resource
    private UserService userService;

    //查询所有员工
    @GetMapping("/queryAllUser")
    public ResultCommon queryAllUser(){
        return userService.queryAllUser();
    }

    //根据id修改用户
    @PostMapping("/updateUser")
    public ResultCommon updateUser(User user){
        return userService.updateUser(user);
    }

    //根据id删除用户
    @GetMapping("/deleteUserById")
    public ResultCommon deleteUserById(int id){
        return userService.deleteUserById(id);
    }

    //添加用户
    @PostMapping("/insertUser")
    public ResultCommon insertUser(User user){
      return userService.insertUser(user);
    }
}
